<template>
  <div>
    <el-table v-loading.body="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column prop="id" label="id" min-width="40" align="center" ></el-table-column>
      <el-table-column prop="dtuId" label="存储id" min-width="40" align="center" ></el-table-column>

      <el-table-column prop="control_id" label="控制器Id" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="customer_id" label="customerId" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="dtu_key" label="dtuKey:" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value1" label="value1" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value2" label="value2" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value3" label="value3" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value4" label="value4" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value5" label="value5" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="value6" label="value6" min-width="60" align="center" ></el-table-column>
      <el-table-column prop="type" label="类型" min-width="30" align="center" ></el-table-column>
      <el-table-column class-name="status-col" label="状态" width="110">
        <template slot-scope="scope">
          <div>{{ scope.row.status | statusName() }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="createdt" label="创建时间" min-width="80" align="center" ></el-table-column>
      <el-table-column align="center" label="操作" width="120">
        <template slot-scope="scope">
          <router-link :to="'/devicedata/detail?id='+scope.row.id">
            <el-button type="primary" size="small" icon="el-icon-edit">详情</el-button>
          </router-link>

        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        :current-page="listQuery.page"
        :page-sizes="[10,20,30, 50]"
        :page-size="listQuery.limit"
        :total="total"
        background
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"/>
    </div>
  </div>

</template>

<script>
import {devicedatahistorylist} from "../../api/devicedatahistory";

export default {
  name: "list",
  filters: {
    statusName(status) {
      if (status===1) {
        return '正常';
      }else{
        return '异常'
      }
    }
  },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      devicedatahistorylist(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.data.count
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.listQuery.page = 1
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    }
  }
}
</script>

<style scoped>

</style>
